package com.chaos.order.controller;

import com.chaos.order.api.data.TOrderData;
import com.chaos.order.service.TOrderService;
import com.chaos.framework.model.dto.ID;
import com.chaos.framework.model.dto.page.PageQueryDto;
import com.chaos.framework.model.dto.result.data.DataResult;
import com.chaos.framework.model.dto.result.list.ListResult;
import com.chaos.framework.model.dto.result.page.PageResult;
import com.chaos.framework.starter.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Jacky.Cui
 * @since 2024-11-22
 */
@Slf4j
@RestController
@Api(tags = "订单表")
@RequestMapping("/tOrder")
public class TOrderController extends BaseController<TOrderData> {
    @Resource
    private TOrderService tOrderService;

    @PostMapping("/one.admin")
    @ApiOperation(value = "订单表详情", httpMethod = "POST")
    public DataResult<TOrderData> one(@RequestBody ID data) {
        return dataResult(tOrderService.selectByID(data));
    }

    @PostMapping("/list.admin")
    @ApiOperation(value = "订单表列表", httpMethod = "POST")
    public ListResult<TOrderData> list(@RequestBody TOrderData data) {
        return listResult(tOrderService.selectByData(data));
    }

    @PostMapping("/page.admin")
    @ApiOperation(value = "订单表分页", httpMethod = "POST")
    public PageResult<TOrderData> page(@RequestBody PageQueryDto<TOrderData> data) {
        return pageResult(tOrderService.selectByPage(data));
    }

    @PostMapping("/add.admin")
    @ApiOperation(value = "新增订单表", httpMethod = "POST")
    public DataResult<ID> add(@RequestBody TOrderData data) {
        return dataResult(tOrderService.insertModel(data));
    }

    @PostMapping("/update.admin")
    @ApiOperation(value = "编辑订单表", httpMethod = "POST")
    public DataResult<Boolean> update(@RequestBody TOrderData data) {
        return dataResult(tOrderService.updateModelByID(data));
    }

    @PostMapping("/delete.admin")
    @ApiOperation(value = "删除订单表", httpMethod = "POST")
    public DataResult<Boolean> delete(@RequestBody ID data) {
        return dataResult(tOrderService.deleteModel(data));
    }



}
